package Integer;

/**
 * Some usefull methods for handling integer arrays
 * 
 * @author Torbjoern Klatt
 */
public class Arrays {
    /**
     * Printing out an integer array well structured using standard
     * Out-Stream.
     * @param array as Integer
     */
    public static void printArray(int[] array) {
        for(int i = 0; i < array.length; i++) {
            System.out.println((i+1) + ". Element is: " + array[i]);
        }
    }
    
    /**
     * Calculating the sum of all entries of an integer array.
     * @param array as Integer
     * @return int
     */
    public static int sumOfArray(int[] array) {
        int result = 0;
        for(int i = 0; i < array.length; i++) {
            result += array[i];
        }
        return result;
    }
    
    /**
     * Calculation the product of all entries of an integer array.
     * @param array as Integer
     * @return int
     */
    public static int productOfArray(int[] array) {
        int result = 1;
        for(int i = 0; i < array.length; i++) {
            result *= array[i];
        }
        return result;
    }
}
